package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Publicity;
import com.hl.sfzy.mapper.PublicityMapper;
import com.hl.sfzy.service.PublicityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PublicityServiceImpl implements PublicityService {
    @Autowired
    private PublicityMapper publicityMapper;
    @Override
    public PageInfo<Publicity> findByPage(int pageNum, int pageSize, Publicity publicity) {
        PageHelper.startPage(pageNum,pageSize);
        List<Publicity> list = publicityMapper.selectAll(publicity);
        PageInfo<Publicity> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int add(Publicity publicity) {
        int i = publicityMapper.insert(publicity);
        return i;
    }

    @Override
    public int edit(Publicity publicity) {
        int i = publicityMapper.updateByPrimaryKey(publicity);
        return i;
    }

    @Override
    public int removeByPrimaryKey(Long id) {
        int i = publicityMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public Publicity findById(Long id) {
        Publicity publicity = publicityMapper.selectByPrimaryKey(id);
        return publicity;
    }

    @Override
    public int deleteBatch(List<Long> ids) {
        int i = publicityMapper.deleteBatch(ids);
        return i;
    }
}
